package com.hhs.storage.controller;


import com.github.xiaoymin.knife4j.annotations.*;
import com.hhs.storage.bean.*;
import com.hhs.storage.service.BaseDepartmentService;
import com.hhs.storage.service.BaseUserService;
import com.hhs.storage.service.ZrReportService;
import com.hhs.storage.util.SysUtil;
import io.swagger.annotations.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  监督管理前端控制器
 * </p>
 * @author yuanjun
 * @since 2024-01-12
 */
@RestController
@RequestMapping("/zrSupervision")
@ApiSupport(order = 1)      //排序
@Api(tags = "监督管理接口")
public class ZrSupervisionController {
    @Resource
    BaseDepartmentService baseDepartmentService;
    @Resource
    BaseUserService baseUserService;
    @Resource
    private HttpServletRequest request;

    /**
     * 获取表格数据
     * @param inputParam
     * @return
     */
    @RequestMapping(value = "table")
    @ApiOperation(value = "得到所有监督数据",
            notes = "得到所有监督数据得到所有监督数据得到所有监督数据",
            httpMethod = "POST"
    )
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = String.class,name = "id", value = "部门id用,分开",required =
                    false,paramType = "query"),
            @ApiImplicitParam(dataTypeClass = String.class,name = "name", value = "搜索姓名",required =
                    false,paramType = "query"),
            @ApiImplicitParam(dataTypeClass = String.class,name = "type", value = "0.日，1.周,2.月",required =
                    false,paramType = "query"),
            @ApiImplicitParam(dataTypeClass = Integer.class,name = "page", value = "页号",required =
                    false,paramType = "query"),
            @ApiImplicitParam(dataTypeClass = Integer.class,name = "size", value = "第页条数",required =
                    false,paramType = "query")
    })

    public ResponseBeanPage<BaseUser> getAll(@ApiIgnore InputParam inputParam) {
        Map<String, Object> map = baseDepartmentService.getUsers(inputParam);
        List<BaseUser> rows = (List<BaseUser>)map.get("rows");
        //处理缺勤率
        baseUserService.doAbsenceAndAttendance(rows,inputParam);
        ResponseBeanPage rep = ResponseBeanPage.getInstance();
        rep.setCode(1);
        rep.setTotal((Long) map.get("total"));
        rep.setRows(rows);
        return rep;
    }
}

